<template>
	<view>
		<view class="cancle-container">
			<c-layout>
				<c-navigation-bar slot="head" :title=" type==7? $t('orderDetails.refund'):  $t('orderDetails.Return/exchange')"></c-navigation-bar>

				<view class="goodsInfo">
					<view class="productBox">
						<view class="productBox_top">
							<view class="productBox-img">
								<u-image :src="type==0||type==7?$u.file.getMedieUrl(goodsDetail.image):$u.file.getMedieUrl(goodsDetail.orderSkuDto.image)"  style="height: 160rpx; width: 160rpx"></u-image>
							
								<view class="middle-box">
									<uni-tooltip :content="goodsDetail.orderSkuDto?goodsDetail.orderSkuDto.name:goodsDetail.name">
										<view class="productBox-tittle">
											{{  goodsDetail.orderSkuDto?goodsDetail.orderSkuDto.name:goodsDetail.name}}
										</view>
									</uni-tooltip>
									<uni-tooltip :content="goodsDetail.orderSkuDto? goodsDetail.orderSkuDto.goodsDesc:goodsDetail.goodsDesc">
										<view class="productBox-introl">
											{{goodsDetail.orderSkuDto? goodsDetail.orderSkuDto.goodsDesc:goodsDetail.goodsDesc }}
										</view>
									</uni-tooltip>
									<view class="number-box">
										<view class="productBox-price">${{goodsDetail.orderSkuDto?goodsDetail.orderSkuDto.money:goodsDetail.money }}</view>
									
										<view class="productBox-num">X{{ goodsDetail.orderSkuDto?goodsDetail.orderSkuDto.num :goodsDetail.num}}</view>
										
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>

				<view class="cancle-box">
					<view class="tittle1">{{$t('orderDetails.reason')}}</view>

					<view class="select">
						<uni-data-select :emptyTips="$t('orderDetails.noOptions')" :placeholder="placeholder1" width="670rpx" height="96rpx" v-model="value" :localdata="range" @change="change" :clear="true"></uni-data-select>
					</view>
					<!-- <view class="">
						<view class="tittle1">Refund amount</view>
						<view class="select-amount">Cannot be modified, at most ${{ goodsDetail.money }}</view>
					</view> -->
					<view class="tittle2">{{$t('orderDetails.description')}} </view>
					<textarea placeholder-class="placeholderClass" :placeholder="placeholder2" name="" id="" cols="30" rows="10" v-model="content"></textarea>
				
					<view class="popop-box1" v-if="type !=7">
						<view class="">
							{{$t('orderDetails.selectType')}}
						</view>
					</view>
					<!-- 退货/退款状态 -->
					<view class="check-box"  v-if="type !=7">
						<uni-data-checkbox 
						v-model="value2" 
						:localdata="range2" 
						@change="change2"
						:multiple="false"
						selectedColor="#1E2432"
						
						class="check-item"
						></uni-data-checkbox>
					</view>		
					
					<button type="default" style="z-index: 999;" class="bottom-btn" @click="goOkPage">
						<u-loading mode="flower" :show="isloading" style="margin-right: 10rpx;"></u-loading>
						{{$t('system.Submit') }}
					</button>
				</view>

				<view>
					<u-toast ref="uToast" />
				</view>
			</c-layout>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			isloading:false,
			value2:1,//退换货状态  默认为退货
			range2:  [{"value": 1,"text":this.$t('orderDetails.Return')	},{"value": 2,"text": this.$t('orderDetails.exchange')},{"value": 3,"text":this.$t('orderDetails.forRefund')}],
			appBaseUrl: process.uniEnv.COSHost,
			type: null,
			range: null,
			content: '',
			goodsDetail: {
				price: 198,
				name: 'Roller Rabbit',
				order: '3324502349KJD2343',
				image: '',
				by: 'Black Heart Institution',
				intro: 'Realize Syirian children',
				qty: '1'
			},
			placeholder1: this.$t('orderDetails.choose') ,
			placeholder2:  this.$t('orderDetails.supplimental'),

			//请求参数
				parmasData:{},
				value: null,
				content: '',
		
			type:null,
			
		};
	},
	methods: {
		getDictType(){
			this.$u.get(`/system/dict/data/type/return_reason`).then((r) => {
				let liss=r.data
				this.range=liss.map(item=>{
				return {
					text: item.dictLabel,
					value: item.dictValue
				}	
				})
				console.log(2321323,this.range);
			});
			
		},
		goOkPage() {
			if(this.type==0){
				this.parmasData = {
					orderSkuId: this.goodsDetail.id,
					idea: this.value,
					description: this.content,
					type:this.value2
				}
			}else if(this.type==7){
				this.parmasData = {
					orderSkuId: this.goodsDetail.id,
					idea: this.value,
					description: this.content,
					type:3
				}
			}else{
				this.parmasData = {
					id:this.goodsDetail.id,
					orderSkuId: this.goodsDetail.orderSkuDto.id,
					idea: this.value,
					description: this.content,
					type:this.value2
					}
			}
			
			this.isloading=true
			this.$u.post(`/app/shopOrderReturnApproved/add`, this.parmasData).then((r) => {
				if (r.code == 200) {
					this.isloading=false
					this.showToast();
					// uni.navigateTo({
					// 	url: '/pages/paymentCancel/paymentCancel?type=' + 0,
					// 	animationType: 'slide-in-right',
					// 	animationDuration: 300
					// });
					
					
				}
			});
			
		},
		showToast() {
			this.$refs.uToast.show({
				title:this.$t('orderDetails.applicationApprov'),
				type: 'success',
				url: '/pages/order/myOrder'
			});
		},
		change(e) {
			console.log('e:', e);
			
		},
		change2(e) {
			console.log('e:', e);
			console.log(this.value2);
		},
		
		
	},
	onLoad(options) {
		this.getDictType()
		// console.log(3333,JSON.parse(decodeURIComponent(options.data)));
		this.type=options.type
		// console.log('this.type',this.type);
		this.goodsDetail = this.vuex_shoping_cartList
		// console.log('goodsDetail',this.goodsDetail);
	}
};
</script>

<style lang="scss" scoped>
/deep/.uni-scroll-view,
.uni-scroll-view-content {
	height: 100%;
}
.goodsInfo {
	border-bottom: 8rpx solid #f2f3f5;
	.productBox {
		background: #ffffff;
		border-radius: 26rpx 26rpx 26rpx 26rpx;
		opacity: 1;
		border: 1px solid #e1e8e8;
		margin: 40rpx;
		padding: 20rpx;

		.productBox_top {
			display: flex;
			padding-bottom: 10px;
			justify-content: space-between;
			.productBox-img {
				display: flex;
				.middle-box {
					width: 450rpx;
					padding-left: 20rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					.productBox-tittle {
						font-size: 30rpx;
						color: #000000;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
					.productBox-introl {
						font-size: 24rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
					.number-box {
						display: flex;
						justify-content: space-between;
						.productBox-num {
							font-size: 30rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							background-color: #dadada;
							border-radius: 12rpx;
							padding: 5rpx;
						}
						.productBox-price {
							font-size: 30rpx;
							color: #000000;
							font-weight: 500;
						}
					}
				}
			}
		}
	}
}
.cancle-box {
	padding: 48rpx 40rpx;
	font-size: 30rpx;
	font-family: SFUIDisplay-Medium-Regular, SFUIDisplay-Medium;
	font-weight: 400;
	color: #212121;
	z-index: 999;

	height: 100%;
}
/deep/.uni-select {
	width: 670rpx;
	height: 96rpx;
	border: 2rpx solid #d2d2d2;
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	margin: 30rpx 0 40rpx 0;
}
/deep/.uni-select__input-placeholder {
	font-size: 30rpx;
	font-family: SFUIDisplay-Medium-Regular, SFUIDisplay-Medium;
	font-weight: 400;
	color: #212121;
}
.select-amount {
	width: 670rpx;
	height: 96rpx;
	border: 2rpx solid #d2d2d2;
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	margin: 30rpx 0 40rpx 0;
	text-align: center;
	line-height: 96rpx;
	font-size: 30rpx;
	font-family: SFUIDisplay-Regular-Regular, SFUIDisplay-Regular;
	font-weight: 400;
	color: #91909a;
}

textarea {
	width: 100%;
	height: 316rpx;
	border: 2rpx solid #d2d2d2;
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	padding: 30rpx;
	box-sizing: border-box;
	margin: 30rpx 0;
}
/deep/.placeholderClass {
	color: #e3e4e5;
}

button {
	width: 670rpx;
	height: 120rpx;
	font-size: 32rpx;
	position: fixed;
	bottom: 58rpx;
	right: 0;
	left: 0;
}
.u-toast {
	width: 450rpx;
	height: 100rpx;
}
.popop-box1{
	margin:20rpx 0;
}
	
.bottom-btn{

	
}
</style>
